#include <head.h>
/*
./001
0002

*/
void dir_Func(const char * dir_name)
{
    printf("dir_name = %s\n" , dir_name);
    sleep(1);

    // 打开目录
    DIR * dir_p = opendir(dir_name);

    struct dirent * dir_s;
    
    char buf[1024];

    while (NULL != (dir_s = readdir(dir_p)))
    {
        if((!strcmp( dir_s->d_name , ".")) || (!strcmp( dir_s->d_name , "..")))
        {
            continue;
        }
        printf("文件名 %s\n" , dir_s->d_name);

        if(dir_s->d_type == DT_DIR)
        {
            sprintf(buf , "%s/%s" , dir_name ,dir_s->d_name );
            // 递归函数    
            dir_Func(buf);
            break;
        }
    }
    
    closedir(dir_p);
}


int main(int argc, char const *argv[])
{
    dir_Func("./001");
    return 0;
}